$(function(){
	
	var id = $.site.request.QueryString("id") ;
	if(undefined != id && "" != id) {
		productTypeList(id) ;
	}
	
});

//产品侧边导航
function productTypeList(id) {
	var sub_left_sider = $("#sub_left_sider") ;
	
	$.post($.site.ctx.baseUrl + "/front/site/productTypeList.do?pid="+id, function(result){
		
		if(result[0].children) {
			sub_left_sider.empty() ;
			$.each(result[0].children, function(i, p){
				sub_left_sider.append("<li><a href='javascript:productList(\""+p.id+"\")'>"+p.colName+"</a></li>") ;
			}); 
			
			productList(result[0].children[0].id);
		}
	}, "JSON") ;
}

function productList(pid, curPage) {
	curPage = (curPage?curPage:1) ;
	var pageSize = 15 ;
	var pageNum = 0
	
	var pageContextList = $("#pageContext") ; //pageContextList.empty()
	var pageDiv = $("#pageDiv") ; //pageDiv.empty()
	
	$.post($.site.ctx.baseUrl + "/front/site/productList.do?sort=pushDate&order=desc", {
		"pid": pid,
		"isPush": 1,
		"pageSize": pageSize,
		"curPage": curPage
	}, function(result){
		
		if(result.total > 0) {
			var total = result.total ;
			if(total % pageSize == 0) {
				pageNum = total / pageSize ;
			} else {
				pageNum = parseInt(total / pageSize) + 1
			}
			
			
			var pc = "";
			$.each(result.rows, function(i, p){
				pc += "<div class='sub_ctx_box'>"+
						"<div class='ctx_jj'>"+
						"<h3><a href='"+$.site.ctx.baseUrl+"/front/site/showDocPage.do?id="+p.id+"&type=services' target='_blank'>"+p.pageTitle+"</a></h3>"+
						"<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
						""+(p.remark==undefined?"":p.remark)+"</p>"+
						"<a href='"+$.site.ctx.baseUrl+"/front/site/showDocPage.do?id="+p.id+"&type=services' target='_blank' class='dp'>详细&gt;&gt;</a>"+
					"</div>"+ 
					"<div class='ctx_pic'>"+
						"<div class='pic_box'>"+
							"<a href='"+$.site.ctx.baseUrl+"/front/site/showDocPage.do?id="+p.id+"&type=services' target='_blank'><img src='"+p.pageLogo+"'/></a>"+
						"</div>"+
					"</div>"+
				"</div>";
			});
			pageContextList.html(pc);
			
			
			//分页
			
			var pn = "";
			pn += "<a href='javascript:productList(\""+pid+"\", "+((curPage+1)>1?(curPage-1):1)+");'>前ページ</a>";
			pn += "<b id='curPage'>"+curPage+"/"+pageNum+"</b>";
			pn += "<a href='javascript:productList(\""+pid+"\", "+((curPage+1)<pageNum?(curPage+1):pageNum)+");'>次ページ</a>";
			
			pageDiv.html(pn) ;
			
		} else {
			alert("找不到数据！！！")
		}
	}, "JSON") ;
}



















 